home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 17 / CU Amiga Magazine's Super CD-ROM 17 (1997)(EMAP Images)(GB)[!][issue 1997-12].iso / CUCD / Programming / DiceSource / lib / string / strstr.c < prev    next >
C/C++ Source or Header  |  1997-09-09  |  545b  |  35 lines

  1.  
  2. /*
  3.  *  STRSTR.C        find one string in another
  4.  *
  5.  *    (c)Copyright 1992-1997 Obvious Implementations Corp.  Redistribution and
  6.  *    use is allowed under the terms of the DICE-LICENSE FILE,
  7.  *    DICE-LICENSE.TXT.
  8.  */
  9.  
  10. #include <string.h>
  11. #include <errno.h>
  12.  
  13. #ifndef HYPER
  14. #define HYPER(x) x
  15. #endif
  16.  
  17. char *
  18. HYPER(strstr)(s1, s2)
  19. const char *s1;
  20. const char *s2;
  21. {
  22.     short len2 = strlen(s2);
  23.  
  24.     if (len2 == 0)
  25.     return(s1);
  26.  
  27.     while (*s1) {
  28.     if (*s1 == *s2 && strncmp(s1, s2, len2) == 0)
  29.         return(s1);
  30.     ++s1;
  31.     }
  32.     return(NULL);
  33. }
  34.  
  35.